package com.resou.reader.data.bookstore;

import com.resou.reader.api.entry.CarousePicBean;
import com.resou.reader.api.entry.CommonData;
import com.resou.reader.api.entry.Result;
import com.resou.reader.api.entry.ResultList;
import com.resou.reader.data.bookstore.model.BasicList;
import com.resou.reader.data.bookstore.model.MorePlateInfo;
import com.resou.reader.data.bookstore.model.PlateNovels;
import com.resou.reader.data.bookstore.response.PlateInfoResponse;

import java.util.List;

import io.reactivex.Observable;

public class BookStoreRepository {
    private final BookStoreService mStoreService;
    private static BookStoreRepository sInstance;

    public static BookStoreRepository getInstance(BookStoreService storeService) {
        if (sInstance == null) {
            sInstance = new BookStoreRepository(storeService);
        }
        return sInstance;
    }

    private BookStoreRepository(BookStoreService storeService) {
        mStoreService = storeService;
    }

    public Observable<List<BasicList<PlateNovels>>> getMainRankList(String gender) {
        return mStoreService.getList(gender).map(ResultList::getData);
    }

    public Observable<CommonData<List<CarousePicBean>>> getBannerPic(String gender) {
        return mStoreService.getBanner(gender).map(Result::getData);
    }

    public Observable<Result<PlateInfoResponse<MorePlateInfo>>> getMoreInfo(String gender, String plateType, int page, int pageNum) {
        return mStoreService.getMoreInfo(gender, plateType, page, pageNum);
    }
//    换一换
    public Observable<ResultList<PlateNovels>> getRepeatList() {
        return mStoreService.getRepeatList();
    }
}
